
#include <BReadWrite>
#include <BCursor>
#include <BPainter>
#include <BMouseEvent>
#include <BClock>
#include "TextWidget.h"

BClock timer;
TextWidget::TextWidget(BWidget* parent) : BWidget(parent)
{
	BFont* font = Read<BFont>("font/times.ttf");
	this->setFont(font);

	BImage* image = static_cast<BImage*>(ReadObject("image/hand/014.png"));
	BCursor* cursor = new BCursor();
	cursor->setType(Cursor_Custom);
	cursor->setImage(image);
	cursor->setPoint(-9, 0);
	cursor->setSize(17, 19);
	//this->setCursor(cursor);

	timer.start();
}
TextWidget::~TextWidget()
{

}

void TextWidget::setImage(BImage* image)
{
	_image = image;
}

void TextWidget::event(const BEvent& event)
{
	BPainter painter(this);

	int width = this->width();
	int height = this->height();

	painter.setColor(BColor(255, 255, 0) * 0.5);
	painter.fillRect(0, 0, width, height);

	painter.setLineWidth(10);
	painter.setColor(BColor(200, 112, 36));
	painter.drawRect(0, 0, width, height);

	painter.drawLine(0, width, height, 0);

	painter.setLineSmooth(true);
	painter.drawLine(0,0, width-100, height-100);

	painter.setColor(BColor(1, 1, 1));
	painter.drawText(10, 10, "This is a test for drawText!");
}

void TextWidget::mousePressEvent(const BMouseEvent& mouseEvent)
{
	if(mouseEvent.button() == Button_Left)
	{
		BPoint mousePos = mouseEvent.pos();
		BPoint abPos = this->absolutePos();
		BPoint glPos = this->globalPos();
	}
}

